<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="js/jquery-3.3.1.min.js"></script>
    <script>
        //定义方法
        function fun() {
            $.post("ajaxServlet", {username: "rose"}, function (data) {
                alert(data);
            });

        }
    </script>

</head>
<body>
<input onclick="fun();" type="button" value="发送">
<input type="text">
</body>
</html>